<layout name="Layout/layout" />
<div class="row">
	<div class="col-lg-12">
		<h1 class="page-header">IP</h1>
	</div>
	<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				IP池
			</div>
			<!-- /.panel-heading -->
			<div class="panel-body">
			<?php
				$head = array(
					'id'	=>	array('ID','doNothing'),
					'name'	=>	array('IP地址','doNothing'),
					'title'	=>	array('备注','doNothing'),
					'isopen'	=>	array('可用？','checkInuse')
				);
			?>
			{:W('Table/tableWithFunction', array($head, $iplist))}
			</div>
			<!-- /.panel-body -->
		</div>
		<!-- /.panel -->
	</div>
	<!-- /.col-lg-12 -->
</div>
<script>
	window.onload = function(){
		$.fn.bootstrapSwitch.defaults.onText = '启用中';
		$.fn.bootstrapSwitch.defaults.offText = '禁用中';
		$.fn.bootstrapSwitch.defaults.onColor = 'success';
		$.fn.bootstrapSwitch.defaults.offColor = 'warning';
		$("[name=isopen]").bootstrapSwitch();
		$('input[name="isopen"]').on('switchChange.bootstrapSwitch', function(event, state) {
		 	var id = $(this).parent().parent().parent().parent().prevAll().last().text();
			$.post("{:U('Admin/Ip/setStatus')}",{
				status: state,
				id: id
			},
			function(data, status){
				console.log(data);
			});
		});
	}
</script>
